#!/usr/bin/env node

const http=require('https'),
      log=console.log,
      url=require('url'),
      city=process.argv[2],
      addr='https://api.66mz8.com/api/weather.php?location='+city;
log(global.encodeURI(addr));
process.exit();
let opt=url.parse(addr);
opt.headers={
  'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11'
};

http.get(addr,(res)=>{
  //print response start line
  //HTTP/1.1 200 OK
  log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);

  //print headers
  ////Content-length:22
  log(res.headers);

  res.pipe(process.stdout);
});
